New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collected small changes and bugfixes #2717
Conversation
reported on MatSci forum: https://matsci.org/t/question-to-fix-atom-swap-function/36135
|
||
if (nlangspin > 0) { | ||
locklangevinspin = new FixLangevinSpin*[nprecspin]; | ||
locklangevinspin = new FixLangevinSpin*[nlangspin]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julient31 ... and here we have a cut-n-paste bug that was detected by using static code analysis with coverity scan.
@@ -197,18 +203,18 @@ void FixNVESpin::init() | |||
int count1 = 0; | |||
if (npairspin == 1) { | |||
count1 = 1; | |||
spin_pairs[0] = (PairSpin *) force->pair_match("spin",0,0); | |||
spin_pairs[0] = (PairSpin *) force->pair_match("^spin",0,0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julient31 please note that not using the caret (^) can lead to false matches, same as for comparisons with strstr()
. There may be styles that are not in the SPIN package and just by accident contain the string "spin" somewhere.
That is why we introduced the utils::strmatch()
function, which has been applied here and is used internally by Force::pair_match()
for inexact matches. Searching for styles that start with the string spin is much more specific.
@@ -172,15 +175,18 @@ void FixNVESpin::init() | |||
|
|||
// loop 1: obtain # of Pairs, and # of Pair/Spin styles | |||
|
|||
if (force->pair_match("spin",0,0)) { // only one Pair/Spin style | |||
pair = force->pair_match("spin",0,0); | |||
npairs = pair->instance_total; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julient31 I noticed this while improving the inexact matches. Pair::instance_total
is not the total number of pair styles but the total number of pair styles ever created. This is to have a unique number to identify pair styles that are otherwise the same, e.g. when using the same pair style as a hybrid sub-style. This is used for example by the neighbor list code to by able to distinguish individual neighbor list requests. So if you replace an initial pair style (say lj/cut with morse) its value will become 2 even though there is only one pair style instance active.
src/velocity.cpp
Outdated
arg[1] = group->names[igroup]; | ||
arg[2] = (char *) "temp"; | ||
temperature = new ComputeTemp(lmp,3,arg); | ||
modify->add_compute(fmt::format("velocity_temp {} temp")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akohlmey that was too simple ;-)
modify->add_compute(fmt::format("velocity_temp {} temp")); | |
modify->add_compute(fmt::format("velocity_temp {} temp", group->names[igroup])); |
Summary
This pull request combines multiple small changes and bugfixes
Author(s)
Axel Kohlmeyer, Temple U
Licensing
By submitting this pull request, I agree, that my contribution will be included in LAMMPS and redistributed under either the GNU General Public License version 2 (GPL v2) or the GNU Lesser General Public License version 2.1 (LGPL v2.1).
Backward Compatibility
No known issues
Implementation Notes
The following individual changes
Post Submission Checklist